package org.newlifecac;

import java.io.File;
import java.util.Properties;

import org.apache.http.util.EncodingUtils;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.text.Html;
import android.view.KeyEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;

public class InfoShow extends Activity implements OnClickListener
{
	private TextView tv_content;
	private Button btnback;
	private static String SD_PATH = android.os.Environment.getExternalStorageDirectory().getAbsolutePath();
	public static File PIC_PATH = new File(SD_PATH + "/Picture/");
	public static File CONFIG_PATH = new File(SD_PATH + "/Newlifecac/");
	public static File CONFIG_FILE = new File(CONFIG_PATH+"/message.properties");

	@Override
	protected void onCreate(Bundle savedInstanceState)
	{
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.content);

		btnback = (Button) findViewById(R.id.btnback);
		btnback.setOnClickListener(this); 
		
		tv_content = (TextView) findViewById(R.id.tv_content);
		tv_content.setText(Html.fromHtml(getHtmlString()));
	}
	
	public void onClick(View v)
	{
		switch (v.getId())
		{
		case R.id.btnback:
			onKeyDown(KeyEvent.KEYCODE_BACK, null);
			break;
		}
	}
	
	@Override
	public boolean onKeyDown(int keyCode, KeyEvent event)
	{
		if (keyCode == KeyEvent.KEYCODE_BACK )
		{
			Intent intent = new Intent();
			intent.setClass(InfoShow.this, FilePickerActivity.class);
			startActivity(intent);
			InfoShow.this.finish();
		}
		return false;
	}
	
	public String getHtmlString()
	{
		String infoString = "";
		if (!CONFIG_FILE.exists())
		{
			String test1 = 
					"<font color=\"red\">周六上午崇拜：</font><br>"
					+ "法拉盛堂 49-49 Sanford Avenue, Flushing, NY 11355<br>"
					+ "10:30 - 11:00  真道洗礼班<br>" + "11:00 - 12:15  崇拜<br>"
					+ "12:30 - 14:00 爱宴及诗班练习<br><br>";
			String test2 = "<font color=\"red\">周日下午崇拜：</font><br>"
					+ "曼哈顿堂  91 Clermont Ave,W. 122nd st, New York, NY 10027<br>"
					+ "3:15 - 3:55  诗班练习,真道洗礼班<br>" + "4:00 - 5:15  崇拜<br>"
					+ "5:30 - 6:30 爱宴及团契活动<br><br>";	
			String test3 = "<font color=\"red\">周一下午崇拜：</font><br>"
					+ "布鲁克林堂   745 59 st, Brooklyn, NY 11220<br>"
					+ "1:00 - 1:30  真道洗礼班<br>" + "1:30 - 2:15  崇拜<br>"
					+ "2:30 - 3:30 茶点及团契活动<br><br>";	
			String test4 = "<font color=\"red\">周二下午崇拜：</font><br>"
					+ "法拉盛堂   49-49 Sanford Avenue, Flushing, NY 11355<br>"
					+ "1:00 - 1:30  真道洗礼班<br>" + "1:30 - 2:30  崇拜<br>"
					+ "2:30 - 3:30 茶点及团契活动<br><br>";	
					
			String test5 = "<font color=\"red\">晚查经祷告会(7:30 - 9:00)</font>";	
			
			infoString = test1+test2+test3+test4+test5;
		}else 
		{
			BackupSetting bSetting = new BackupSetting();
			System.out.println("Configuration Path-->"+CONFIG_FILE);
			Properties pro = bSetting.loadConfig(this,CONFIG_FILE+"");
			infoString = (String) pro.get("InfoShow");
			
		}
		return infoString;
		
	}
}
